﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXBase.Structs
{
	public static class Utils
	{
		public static readonly float PI = (float)Math.PI;

		public static float DegToRad(this float degrees)
		{
			return PI * degrees / 180.0f;
		}
		public static float RadToDeg(this float radians)
		{
			return 180.0f * radians / PI;
		}

		public static float Sqrtf(this float v) { return (float)Math.Sqrt(v); }
		public static float Cosf(this float v) { return (float)Math.Cos(v); }
		public static float Sinf(this float v) { return (float)Math.Sin(v); }
		public static float Acosf(this float v) { return (float)Math.Acos(v); }
		public static float Asinf(this float v) { return (float)Math.Asin(v); }
		public static float Atan2f(float y, float x) { return (float)Math.Atan2(y, x); }
		public static float Absf(this float f) { return f < 0 ? -f : f; }
		public static float Tanf(this float f) { return (float)Math.Tan(f); }

		public static float Colorf(this byte b) { return b / 255.0f; }
		public static byte Colorb(this float f) 
		{
			if (f < 0)
				return 0;
			if (f > 1)
				return 255;
			return (byte)Math.Round(f * 255);
		}
	}
}
